package RKUjava.lang;

/** This class replaces the Integer class defined by Sun. <br>
The main difference between Integer and RKUInteger is that RKUInteger 
support setting the value of the wrapped <tt>int</tt>. The main use of this
is the following. Suppose you have an integer object referenced by many other
object and you want to change the value of the integer. This can't be done
with Suns Integer because it doesn't support setting the value.
<br><br>
<b> Implementation details:</b><br>
<ul>
<li>Since Suns Integer class is final it can't be extended. Instead RKUInteger
extends the Number class. 
<li>The class implements the same
methods as Suns Integer class. These methods are implemented by calling
the methods in the Integer class, i.e. they do exactly the same.
</ul>
@author Rasmus K. Ursem, <a href="mailto:ursem@daimi.au.dk">ursem@daimi.au.dk</a>
*/
public class RKUInteger extends Number
{

  /** 
    @serial
  */
  private int val;

  public RKUInteger(int value)
    {
      super();
      val = value;
    }

  /** Returns the value of the specified number as a byte. */
  public byte byteValue() 
    {
      return (byte)val;
    }

  /** Returns the value of the specified number as a double. */
  public double doubleValue() 
    {
      return (double)val;
    }

  /** Returns the value of the specified number as a float. */
  public float floatValue() 
    {
      return (float)val;
    }
  /** Returns the value of the specified number as an int. */
  public int intValue() 
    {
      return val;
    }

  /** Returns the value of the specified number as a long. */
  public long longValue() 
    {
      return (long)val;
    }

  /** Returns the value of the specified number as a short. */
  public short shortValue() 
    {
      return (short)val;
    }

  /** Set the value of this RKUInteger. */
  public void setValue(int newvalue)
    {
      val = newvalue;
    };

  /** Add a value to this RKUInteger. */
  public void addValue(int value)
    {
      val = val+value;
    }

  /** Subtract a value from this RKUInteger. */
  public void subValue(int value)
    {
      val = val-value;
    }

  /** Multiply this RKUInteger by <tt>value</tt>. */
  public void multValue(int value)
    {
      val = val*value;
    }

  /** Devide this RKUInteger by <tt>value</tt>. NOTE: divValue does not throw
   exceptions if <tt>value</tt> is zero but the Java VM does. */
  public void divValue(int value)
    {
      val = val/value;
    }

  /* To be implemented
  decode(String) 
  equals(Object) 
  getInteger(String) 
  getInteger(String, int) 
  getInteger(String, Integer) 
  hashCode() 
  parseInt(String) 
  parseInt(String, int) 
  toBinaryString(int) 
  toHexString(int) 
  toOctalString(int) 
  toString() 
  toString(int) 
  toString(int, int) 
  valueOf(String) 
  valueOf(String, int) 
  */
}





